package com.upnp.action;

import android.content.Context;
import android.database.Cursor;

public class CommDatabase {
	private final Context m_con;
	private DBAdapter m_db;
	
	public CommDatabase(Context con){
		m_con = con;
		m_db  = new DBAdapter(m_con);
	}
	
	public void openDatabase(){
		m_db.open();
	}
	
	public long insertContact(String account, String contact, String email){
		return m_db.insertContact(account, contact, email);
	}
	
	public long insertContact(String contact, String email){
		String account = "NULL";
		return m_db.insertContact(account, contact, email);
	}
	
	public boolean deleteContact(long rowId) {  
		return m_db.deleteContact(rowId);
	}
	
	public boolean deleteContact(String contact) {  
		return m_db.deleteContact(contact);
	}
	
	public Cursor getContact(long rowId){
		return m_db.getContact(rowId);
	}
	
	public Cursor getContact(String contact){
		return m_db.getContact(contact);
	}
	
	public Cursor getAllContacts(){
		return m_db.getAllContacts();
	}
	
	public boolean updateContact(long rowId, String account, String contact, String email){
		return m_db.updateContact(rowId, account, contact, email);
	}
	
	public boolean updateContact(long rowId, String contact, String email){
		String account = "NULL";
		return m_db.updateContact(rowId, account, contact, email);
	}
	
	public void closeDatabase(){
		m_db.close();
	}
}
